package game.controler.gestionnaires.elementjeu;

import game.impl.objets.decors.p3_garde_ko;
import game.impl.objets.pnj.*;
import game.model.objets.PNJ;
import java.util.ArrayList;
import java.util.HashMap;

/**
 *
 * @author Gab'z
 */
public class GestionnairePnj {

    private static GestionnairePnj Gpnj = null;
    private HashMap listePnj = new HashMap<String, PNJ>();
    private HashMap<String, ArrayList<String>> listesIdPlanPnj = new HashMap<String, ArrayList<String>>();

    private GestionnairePnj() {
        System.out.println("Initialisation des PNJs");
        initialiserPnj();
    }

    public static GestionnairePnj getGpnj() {
        if (Gpnj == null) {
            Gpnj = new GestionnairePnj();
        }
        return Gpnj;
    }

    public PNJ getPNJ(String ID) {
        return (PNJ) listePnj.get(ID);
    }

    private void initialiserPnj() {
        // A répéter pour chaque PNJ du jeu
       // ajouterPnj(new vous());
       // ajouterPnj(new perso());
        
        // PLAN_0
        ajouterPnj(new p0_medecin_intro());
        ajouterPnj(new p0_medecin_ko());

        // PLAN_3
        ajouterPnj(new p3_garde1());
        ajouterPnj(new p3_garde2());
        ajouterPnj(new p3_gardes_peur());
    }

    private void ajouterPnj(PNJ pnj) {
        listePnj.put(pnj.getId(), pnj);
        ArrayList<String> listeStringPnj = listesIdPlanPnj.get(pnj.getIdPlan());
        if (listeStringPnj == null) {
            listeStringPnj = new ArrayList<String>(0);
        }
        listeStringPnj.add(pnj.getId());
        listesIdPlanPnj.put(pnj.getIdPlan(), listeStringPnj);
    }

    public ArrayList<String> getListePnjPlan(String idPlanCourant) {
        System.out.println("getListePnjPlan id = " + idPlanCourant);
        ArrayList<String> listePnjPlan = listesIdPlanPnj.get(idPlanCourant);
        if (listePnjPlan == null) {
            return new ArrayList<String>(0);
        }
        return listePnjPlan;
    }
}
